/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import { Form, Button, Badge, Select, DatePicker, Radio, Descriptions, Input, Upload, Icon, TreeSelect } from 'antd';
import {connect} from 'dva';
import moment from 'moment'
import request from '@/utils/request';

const { TextArea } = Input;
const { Option } = Select;
const TreeNode = TreeSelect.TreeNode;
const MonthPicker =DatePicker.MonthPicker

const ButtonGroup = Button.Group;
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      all_staffs:[],
      all_organizations:[],
      format:'YYYY-MM-DD',
      all_party_members:[]
    };
  }
  componentDidMount() {
    const that=this;
    request(`/all_party_members`, {
      method: 'GET',
      params:{
        type:5
      }
    }).then((response) => {
      if (response.status === 200) {
        that.setState({
          all_party_members: response.data.data,
        });
      }

    });
  }
  render() {
    const {getFieldDecorator} = this.props.form;
    return (
      <div>
        <Form>
          <Descriptions className={'blue-descriptions'} title={<div style={{textAlign:'center',marginTop:'10px'}}>党费缴纳</div>} bordered>
            <Descriptions.Item label="缴费党员" span={3}>
              {getFieldDecorator('party_member_id', {
                initialValue:this.props.editRecord?this.props.editRecord.party_member.id:'',
              })(
                <Select disabled={this.props.editRecord}  style={{ width: '100%' }} allowClear={false} >
                  {
                    this.state.all_party_members.map((item, index) => {
                      return <Option key={index} value={item.id}>{item.name}</Option>;
                    })
                  }
                </Select>
              )}
            </Descriptions.Item>
            <Descriptions.Item label="缴费所属月份" span={3}>
              {getFieldDecorator('month', {
                initialValue:this.props.editRecord? moment(this.props.editRecord.month):moment(),
              })(
                <MonthPicker  style={{width:'100%'}}/>
              )}
            </Descriptions.Item>
            <Descriptions.Item label="缴费金额" span={3}>
              {getFieldDecorator('amount', {
                initialValue:this.props.editRecord?this.props.editRecord.amount:'',
              })(
                <Input />
              )}
            </Descriptions.Item>

            <Descriptions.Item label="备注" span={3}>
              {getFieldDecorator('remark', {
                initialValue:this.props.editRecord?this.props.editRecord.remark:'',
              })(
                <Input />
              )}
            </Descriptions.Item>
          </Descriptions>
        </Form>

      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);


